home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group00b.txt
/
000134_icon-group-sender_Tue Oct 31 16:32:06 2000.msg
< prev
next >
Wrap
Internet Message Format
|
2001-01-03
|
3KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id e9VNT7u23929
for icon-group-addresses; Tue, 31 Oct 2000 16:29:07 -0700 (MST)
Message-Id: <200010312329.e9VNT7u23929@baskerville.CS.Arizona.EDU>
From: Chris.D.Tenaglia@jci.com
Subject: favorites
To: icon-group@cs.arizona.edu
Date: Tue, 31 Oct 2000 16:29:28 -0600
X-MIMETrack: Serialize by Router on jwimkrs1.na.jci.com/NA/Johnson_Controls(Release 5.0.4
|June 8, 2000) at 10/31/2000 04:37:23 PM
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 2361
Since this list is getting more active here are some of my favorite
procedures.
The IPL is full of goodies. Some below may be there, but recently I have
been
doing more with the web and CGI, and it's great to build software when you
have
a giant software chip library and are fairly familiar with it. Just a
couple includes,
a main() and you're done. The procedures below I use extensively, every day
and they sure help.
Chris Tenaglia, tech analyst, jci
#
# parse a string into a list with respect to a delimiter
#
procedure parse(line,delims)
static chars
chars := &cset -- delims
tokens := []
line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
return tokens
end
#
# prompt for an input string
#
procedure input(prompt)
writes(prompt)
return read()
end
#
# parse a cgi query string into a table
#
procedure cgiparse(text)
parts := parse(text,'&')
lookup:= table("n/a")
every part := !parts do
{
var := parse(part,'=')[1]
val := map(parse(part,'=')[2],"+"," ") | ""
lookup[unurl(var)] := map(unurl(val),"\r"," ")
}
return lookup
end
#
# error handler if program called wrong
#
procedure error()
write("content-type: text/html")
write("")
write("<HTML>")
write("<HEAD><TITLE>BAD CALL</TITLE></HEAD>")
write("<BODY BGCOLOR=80000><font color=#ffffff>")
write("<PRE><B>\n\n\n")
write("PROGRAM CALLED INCORRECTLY")
write("\n\n\n</B></PRE>")
write("</body>")
stop("</html>")
end
#
# This procedure maps the wierd characters out of cgi query strings
#
procedure unurl(text)
static hex
initial {
hex := table("")
hex["0"] := 0 ; hex["1"] := 1 ; hex["2"] := 2 ; hex["3"] := 3
hex["4"] := 4 ; hex["5"] := 5 ; hex["6"] := 6 ; hex["7"] := 7
hex["8"] := 8 ; hex["9"] := 9 ; hex["a"] := 10; hex["A"] := 10
hex["b"] := 11; hex["B"] := 11; hex["c"] := 12; hex["C"] := 12
hex["d"] := 13; hex["D"] := 13; hex["e"] := 14; hex["E"] := 14
hex["f"] := 15; hex["F"] := 15
}
work := map(text,"+"," ")
cache := []
every i := 1 to *work do if work[i] == "%" then put(cache,i)
while i := pull(cache) do
{
nyb1 := work[i+1]
nyb2 := work[i+2]
if (nyb1 == "") | (nyb2 == "") then next
raw := hex[nyb1] * 16 + hex[nyb2]
byte := char(raw)
work[i+:3] := byte
}
return work
end